package com.QK.cnstudy;

import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.QK.cnstudy.db.DBManager;
import com.QK.cnstudy.entity.Author;

public class AuthorIntroductionActivity extends Activity implements OnClickListener {

    private int authorId;
    private TextView titleTextView;
    private TextView contentTextView;
    private DBManager dbManager;
    private String titleString;
    private String contentString;

    Button backButton;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.author_introduction);
        getView();
        Bundle bundle = getIntent().getExtras();
        dbManager = CnStudyApp.app.dbManager;
        authorId = bundle.getInt("id");
        Author author = dbManager.getAuthorById(authorId);
        titleString = author.getName();
        contentString = "";
        contentString += author.getInfo();
        contentString += "<br/><br/><br/>";
        titleTextView.setText(titleString);
        contentTextView.setText(Html.fromHtml(contentString));
        backButton.setOnClickListener(this);
    }

    public void getView() {
        titleTextView = (TextView) findViewById(R.id.state);
        contentTextView = (TextView) findViewById(R.id.content);
        backButton = (Button) findViewById(R.id.back);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.back:
            onBackPressed();
            break;

        default:
            break;
        }

    }
}
